<?php
function addqqyyzm($qqhao,$qqmima,$r,$extend,$r_sid,$sid,$ip,$hidpw,$verify){
$post_data = array(
'qq='.$qqhao,
'mima='.$qqmima,
'u_token='.$qqhao,
'hexpwd='.$hidpw,
'sidtype=1',
'hexp=true',
'auto=0',
'modifySKey=0',
'q_status=20',
'r='.$r,
'loginType=3',
'imgType=gif',
'extend='.$extend,
'r_sid='.$r_sid,
'bid_code=qqchatLogin',
'toQQchat=falsh',
'rip='.$ip,
'verify='.$verify,
'bid=0',
);
$post_data = implode('&',$post_data);
$url='http://pt.3g.qq.com/handleLogin?sid='.$sid.'&amp;vdata=';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
curl_close($ch);
return $out;
}
function addqqwyzm($qqhao,$qqmima){
$post_data = array(
'qq='.$qqhao,
'pwd='.$qqmima,
'bid_code=3GQQ',
'toQQchat=true',
'login_url=http://pt.3g.qq.com/s?aid=nLoginnew&q_from=3GQQ',
'modifySKey=0',
'loginType=1',
'aid=nLoginHandle',
);
$post_data = implode('&',$post_data);
$url='http://pt.3g.qq.com/psw3gqqLogin?r=777151794&vdata='.md5(time());
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
curl_close($ch);
return $out;
}

function addqq($qq,$mima){
if ($qq==""){
$out="NOQQ";
}elseif($mima==""){
$out="NOMIMA";
}elseif (isset($_POST['yzm'])){
$out=addqqyyzm($_POST['qq'],$_POST['mima'],$_POST['r'],$_POST['extend'],$_POST['r_sid'],$_POST['sid'],$_POST['ip'],$_POST['hidpw'],$_POST['verify']);
}else{
$out=addqqwyzm($qq,$mima);
}
return $out;
}

function panduanqq($out,$qq,$mima,$qid,$fwq,$cookieuser,$qqnum){

$mysqlqq = mysql_query("SELECT * FROM xige_qqlist WHERE email='$cookieuser' and qq='$qq'");
$sqlqq = mysql_fetch_array($mysqlqq);

if ($out=="NOQQ"){
echo "QQ号码不能为空";
}elseif($out=="NOMIMA"){
echo "QQ密码不能为空";
}elseif($qq==$sqlqq['qq']){
echo "此Q已列表,请勿重复!";
}elseif(preg_match("/您输入的账号不存在/",$out)){
echo "腾讯提示:QQ账号不存在";
}elseif(preg_match("/操作异常/",$out)){
$a=explode('/请输入上图字符(不区分大小写)：',$out);
$outt=$a[0];
$b=$a[1];
$img=explode('src="',$outt);
$img=explode('" alt="',$img[1]);
$rt=explode('name="r" value="',$out);
$rw=explode('"/>',$rt[1]);
$extendt=explode('name="extend" value="',$out);
$extendw=explode('"/>',$extendt[1]);
$r_sidt=explode('name="r_sid" value="',$out);
$r_sidw=explode('"/>',$r_sidt[1]);
$login_urlt=explode('name="login_url" value="',$out);
$login_urlw=explode('"/>',$login_urlt[1]);
$sidt=explode('name="sid" value="',$out);
$sidw=explode('"/>',$sidt[1]);
$ipt=explode('name="rip" value="',$out);
$ipw=explode('"/>',$ipt[1]);
$hidpwt=explode('name="hexpwd" value="',$out);
$hidpww=explode('"/>',$hidpwt[1]);
echo '<form action="" method="post">';
echo '输入QQ验证码:';
echo '<div id="addqqyes-left">';
echo '<img src="'.$img[0].'" width="100px">';
echo '<input type="hidden" name="qq" value="'.$qq.'"/>';
echo '<input type="hidden" name="mima" value="'.$mima.'"/>';
echo '<input type="hidden" name="r" value="'.$rw[0].'"/>';
echo '<input type="hidden" name="extend" value="'.$extendw[0].'"/>';
echo '<input type="hidden" name="r_sid" value="'.$r_sidw[0].'"/>';
echo '<input type="hidden" name="login_url" value="'.$login_urlw[0].'"/>';
echo '<input type="hidden" name="sid" value="'.$sidw[0].'"/>';
echo '<input type="hidden" name="ip" value="'.$ipw[0].'">';
echo '<input type="hidden" name="hidpw" value="'.$hidpww[0].'">';
echo '</div>';
echo '<div id="addqqyes-right">';
echo '<input type="text" name="verify" value="">';
echo '</div>';
echo '<div id="addqqyes-button">';
echo '<input type="submit" name="yzm" value="马上登录">';
echo '</div>';
echo '</form>';
}elseif(preg_match("/暂时无法登录/",$out)){
echo '您的帐号暂时无法登录，请到<a href="http://aq.qq.com/007" target="_blank">http://aq.qq.com/007</a>恢复正常使用。';
}elseif(preg_match("/密码不正确/",$out)){
echo '腾讯提示:密码不正确';
}elseif(preg_match("/系统繁忙/",$out)){
echo "腾讯提示:系统繁忙";
}elseif(preg_match("/登录3GQQ成功/",$out)){
$out=explode('sid=',$out);
$sid=substr($out[1],0,24);
$time=time();
$qqnum=$qqnum+1;

mysql_query("INSERT INTO xige_qqlist (id,fwq,qid,email,qq,qqol,mima,sid,sidol,adddate) VALUES ('','$fwq','$qid','$cookieuser','$qq','0','$mima','$sid','0','$time')");
mysql_query("INSERT INTO xige_".$fwq." (id,qid,email,qq,mima,sid,adddate,emailtime) VALUES ('','$qid','$cookieuser','$qq','$mima','$sid','$time','0')");

mysql_query("Update xige_info set qqnum='$qqnum' where email='$cookieuser'");

file_get_contents("http://ti.3g.qq.com/g/s?sid=" . $sid . "&r=" . $qq. "&aid=arelate&ac=42&tu=weibiantai&bid=h%23QQGenius%230%230%230%2316");
echo "小伙伴!记录添加成功啦!";
}else{
echo "未知错误!请联系管理员";
}
}

function fuwuqirand(){
$fwq[1]="server1";
$fwq[2]="server2";
$fwq[3]="server3";
$fuwu=$fwq[rand(1,3)];
return $fuwu;
}

function qidcz(){
$time=date("YmdHis");
$rand=rand(1000000000,9999999999);
$qidcz=$time."".$rand;
return $qidcz;
}


?>